#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,r[N],jun[N];
int work(){
	int ma=0,k=1,l=1,mi=0;//ma:maximum; mi:minimum
	int o=n,p=n;//o:the number of left ones;p:the number of stronger monsters
	for (int i=1;i<=n;i++){
		if(ma!=100000)ma=max(ma,r[i]);
		if(mi!=1) mi=min(mi,r[i]);
		jun[r[i]]++;
	}
	for (int i=1;i<=ma;i++){
		for (int j=1;j<=jun[i];j++,l++){
			r[l]=i;
		}
	}
	l=1;
	k=mi;
	while(k <= ma){
		int num = jun[k];
		p -= num;
		if(p >= num){
			o -= num;
			l += num;
			k = r[l];
		}
		else{
			o-=p;
			break;
		}
	}
	return o;
}
int main(){
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&r[i]);
	}
	int cnt=work();
	printf("%d",cnt);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
